home *** CD-ROM | disk | FTP | other *** search
/ Halting the Hacker - A P…uide to Computer Security / Halting the Hacker - A Practical Guide to Computer Security.iso / rfc / rfc1055.txt < prev    next >
Text File  |  1997-04-01  |  13KB  |  334 lines

  1. Network Working Group                                          J. Romkey
  2. Request for Comments: 1055                                     June l988
  3.  
  4.  A NONSTANDARD FOR TRANSMISSION OF IP DATAGRAMS OVER SERIAL LINES: SLIP
  5.  
  6. INTRODUCTION
  7.  
  8.    The TCP/IP protocol family runs over a variety of network media:
  9.    IEEE 802.3 (ethernet) and 802.5 (token ring) LAN's, X.25 lines,
  10.    satellite links, and serial lines.  There are standard encapsulations
  11.    for IP packets defined for many of these networks, but there is no
  12.    standard for serial lines.  SLIP, Serial Line IP, is a currently a de
  13.    facto standard, commonly used for point-to-point serial connections
  14.    running TCP/IP.  It is not an Internet standard.  Distribution of
  15.    this memo is unlimited.
  16.  
  17. HISTORY
  18.  
  19.    SLIP has its origins in the 3COM UNET TCP/IP implementation from the
  20.    early 1980's.  It is merely a packet framing protocol: SLIP defines a
  21.    sequence of characters that frame IP packets on a serial line, and
  22.    nothing more. It provides no addressing, packet type identification,
  23.    error detection/correction or compression mechanisms.  Because the
  24.    protocol does so little, though, it is usually very easy to
  25.    implement.
  26.  
  27.    Around 1984, Rick Adams implemented SLIP for 4.2 Berkeley Unix and
  28.    Sun Microsystems workstations and released it to the world.  It
  29.    quickly caught on as an easy reliable way to connect TCP/IP hosts and
  30.    routers with serial lines.
  31.  
  32.    SLIP is commonly used on dedicated serial links and sometimes for
  33.    dialup purposes, and is usually used with line speeds between 1200bps
  34.    and 19.2Kbps.  It is useful for allowing mixes of hosts and routers
  35.    to communicate with one another (host-host, host-router and router-
  36.    router are all common SLIP network configurations).
  37.  
  38. AVAILABILITY
  39.  
  40.    SLIP is available for most Berkeley UNIX-based systems.  It is
  41.    included in the standard 4.3BSD release from Berkeley.  SLIP is
  42.    available for Ultrix, Sun UNIX and most other Berkeley-derived UNIX
  43.    systems.  Some terminal concentrators and IBM PC implementations also
  44.    support it.
  45.  
  46.    SLIP for Berkeley UNIX is available via anonymous FTP from
  47.    uunet.uu.net in pub/sl.shar.Z.  Be sure to transfer the file in
  48.    binary mode and then run it through the UNIX uncompress program. Take
  49.  
  50.  
  51.  
  52. Romkey                                                          [Page 1]
  53.  
  54. RFC 1055                     Serial Line IP                    June 1988
  55.  
  56.  
  57.    the resulting file and use it as a shell script for the UNIX /bin/sh
  58.    (for instance, /bin/sh sl.shar).
  59.  
  60. PROTOCOL
  61.  
  62.    The SLIP protocol defines two special characters: END and ESC. END is
  63.    octal 300 (decimal 192) and ESC is octal 333 (decimal 219) not to be
  64.    confused with the ASCII ESCape character; for the purposes of this
  65.    discussion, ESC will indicate the SLIP ESC character.  To send a
  66.    packet, a SLIP host simply starts sending the data in the packet.  If
  67.    a data byte is the same code as END character, a two byte sequence of
  68.    ESC and octal 334 (decimal 220) is sent instead.  If it the same as
  69.    an ESC character, an two byte sequence of ESC and octal 335 (decimal
  70.    221) is sent instead.  When the last byte in the packet has been
  71.    sent, an END character is then transmitted.
  72.  
  73.    Phil Karn suggests a simple change to the algorithm, which is to
  74.    begin as well as end packets with an END character.  This will flush
  75.    any erroneous bytes which have been caused by line noise.  In the
  76.    normal case, the receiver will simply see two back-to-back END
  77.    characters, which will generate a bad IP packet.  If the SLIP
  78.    implementation does not throw away the zero-length IP packet, the IP
  79.    implementation certainly will.  If there was line noise, the data
  80.    received due to it will be discarded without affecting the following
  81.    packet.
  82.  
  83.    Because there is no 'standard' SLIP specification, there is no real
  84.    defined maximum packet size for SLIP.  It is probably best to accept
  85.    the maximum packet size used by the Berkeley UNIX SLIP drivers: 1006
  86.    bytes including the IP and transport protocol headers (not including
  87.    the framing characters).  Therefore any new SLIP implementations
  88.    should be prepared to accept 1006 byte datagrams and should not send
  89.    more than 1006 bytes in a datagram.
  90.  
  91. DEFICIENCIES
  92.  
  93.    There are several features that many users would like SLIP to provide
  94.    which it doesn't.  In all fairness, SLIP is just a very simple
  95.    protocol designed quite a long time ago when these problems were not
  96.    really important issues.  The following are commonly perceived
  97.    shortcomings in the existing SLIP protocol:
  98.  
  99.       - addressing:
  100.  
  101.          both computers in a SLIP link need to know each other's IP
  102.          addresses for routing purposes.  Also, when using SLIP for
  103.          hosts to dial-up a router, the addressing scheme may be quite
  104.          dynamic and the router may need to inform the dialing host of
  105.  
  106.  
  107.  
  108. Romkey                                                          [Page 2]
  109.  
  110. RFC 1055                     Serial Line IP                    June 1988
  111.  
  112.  
  113.          the host's IP address.  SLIP currently provides no mechanism
  114.          for hosts to communicate addressing information over a SLIP
  115.          connection.
  116.  
  117.       - type identification:
  118.  
  119.          SLIP has no type field.  Thus, only one protocol can be run
  120.          over a SLIP connection, so in a configuration of two DEC
  121.          computers running both TCP/IP and DECnet, there is no hope of
  122.          having TCP/IP and DECnet share one serial line between them
  123.          while using SLIP.  While SLIP is "Serial Line IP", if a serial
  124.          line connects two multi-protocol computers, those computers
  125.          should be able to use more than one protocol over the line.
  126.  
  127.       - error detection/correction:
  128.  
  129.          noisy phone lines will corrupt packets in transit. Because the
  130.          line speed is probably quite low (likely 2400 baud),
  131.          retransmitting a packet is very expensive.  Error detection is
  132.          not absolutely necessary at the SLIP level because any IP
  133.          application should detect damaged packets (IP header and UDP
  134.          and TCP checksums should suffice), although some common
  135.          applications like NFS usually ignore the checksum and depend on
  136.          the network media to detect damaged packets.  Because it takes
  137.          so long to retransmit a packet which was corrupted by line
  138.          noise, it would be efficient if SLIP could provide some sort of
  139.          simple error correction mechanism of its own.
  140.  
  141.       - compression:
  142.  
  143.          because dial-in lines are so slow (usually 2400bps), packet
  144.          compression would cause large improvements in packet
  145.          throughput. Usually, streams of packets in a single TCP
  146.          connection have few changed fields in the IP and TCP headers,
  147.          so a simple compression algorithms might just send the changed
  148.          parts of the headers instead of the complete headers.
  149.  
  150.    Some work is being done by various groups to design and implement a
  151.    successor to SLIP which will address some or all of these problems.
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164. Romkey                                                          [Page 3]
  165.  
  166. RFC 1055                     Serial Line IP                    June 1988
  167.  
  168.  
  169. SLIP DRIVERS
  170.  
  171.    The following C language functions send and receive SLIP packets.
  172.    They depend on two functions, send_char() and recv_char(), which send
  173.    and receive a single character over the serial line.
  174.  
  175.    /* SLIP special character codes
  176.     */
  177.    #define END             0300    /* indicates end of packet */
  178.    #define ESC             0333    /* indicates byte stuffing */
  179.    #define ESC_END         0334    /* ESC ESC_END means END data byte */
  180.    #define ESC_ESC         0335    /* ESC ESC_ESC means ESC data byte */
  181.  
  182.    /* SEND_PACKET: sends a packet of length "len", starting at
  183.     * location "p".
  184.     */
  185.    void send_packet(p, len)
  186.            char *p;
  187.            int len; {
  188.  
  189.      /* send an initial END character to flush out any data that may
  190.       * have accumulated in the receiver due to line noise
  191.       */
  192.         send_char(END);
  193.  
  194.      /* for each byte in the packet, send the appropriate character
  195.       * sequence
  196.       */
  197.            while(len--) {
  198.                    switch(*p) {
  199.                    /* if it's the same code as an END character, we send a
  200.                     * special two character code so as not to make the
  201.                     * receiver think we sent an END
  202.                     */
  203.                    case END:
  204.                            send_char(ESC);
  205.                            send_char(ESC_END);
  206.                            break;
  207.  
  208.                    /* if it's the same code as an ESC character,
  209.                     * we send a special two character code so as not
  210.                     * to make the receiver think we sent an ESC
  211.                     */
  212.                    case ESC:
  213.                            send_char(ESC);
  214.                            send_char(ESC_ESC);
  215.                            break;
  216.  
  217.  
  218.  
  219.  
  220. Romkey                                                          [Page 4]
  221.  
  222. RFC 1055                     Serial Line IP                    June 1988
  223.  
  224.  
  225.                    /* otherwise, we just send the character
  226.                     */
  227.                    default:
  228.                            send_char(*p);
  229.                            }
  230.  
  231.                    p++;
  232.                    }
  233.  
  234.            /* tell the receiver that we're done sending the packet
  235.             */
  236.            send_char(END);
  237.            }
  238.  
  239.    /* RECV_PACKET: receives a packet into the buffer located at "p".
  240.     *      If more than len bytes are received, the packet will
  241.     *      be truncated.
  242.     *      Returns the number of bytes stored in the buffer.
  243.     */
  244.    int recv_packet(p, len)
  245.            char *p;
  246.            int len; {
  247.            char c;
  248.            int received = 0;
  249.  
  250.            /* sit in a loop reading bytes until we put together
  251.             * a whole packet.
  252.             * Make sure not to copy them into the packet if we
  253.             * run out of room.
  254.             */
  255.            while(1) {
  256.                    /* get a character to process
  257.                     */
  258.                    c = recv_char();
  259.  
  260.                    /* handle bytestuffing if necessary
  261.                     */
  262.                    switch(c) {
  263.  
  264.                    /* if it's an END character then we're done with
  265.                     * the packet
  266.                     */
  267.                    case END:
  268.                            /* a minor optimization: if there is no
  269.                             * data in the packet, ignore it. This is
  270.                             * meant to avoid bothering IP with all
  271.                             * the empty packets generated by the
  272.                             * duplicate END characters which are in
  273.  
  274.  
  275.  
  276. Romkey                                                          [Page 5]
  277.  
  278. RFC 1055                     Serial Line IP                    June 1988
  279.  
  280.  
  281.                             * turn sent to try to detect line noise.
  282.                             */
  283.                            if(received)
  284.                                    return received;
  285.                            else
  286.                                    break;
  287.  
  288.                    /* if it's the same code as an ESC character, wait
  289.                     * and get another character and then figure out
  290.                     * what to store in the packet based on that.
  291.                     */
  292.                    case ESC:
  293.                            c = recv_char();
  294.  
  295.                            /* if "c" is not one of these two, then we
  296.                             * have a protocol violation.  The best bet
  297.                             * seems to be to leave the byte alone and
  298.                             * just stuff it into the packet
  299.                             */
  300.                            switch(c) {
  301.                            case ESC_END:
  302.                                    c = END;
  303.                                    break;
  304.                            case ESC_ESC:
  305.                                    c = ESC;
  306.                                    break;
  307.                                    }
  308.  
  309.                    /* here we fall into the default handler and let
  310.                     * it store the character for us
  311.                     */
  312.                    default:
  313.                            if(received < len)
  314.                                    p[received++] = c;
  315.                            }
  316.                    }
  317.            }
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. Romkey                                                          [Page 6]
  333.  
  334.